package com.appgole.provider;

import cn.hutool.poi.excel.ExcelUtil;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by Administrator on 2019/3/3.
 */
public class GankExcel {

    /**
     * 文件路径
     */
    private static final String path = "E:\\MyPractice\\IdeaProjects\\testng-demo\\src\\main\\resources\\gankapi.xlsx";


    public static Iterator<Object[]> provideXuanduSubcategory() {
        List<Object[]> result = new ArrayList<>();
        List<List<Object>> list = ExcelUtil.getReader(path, 0).read(1);
        if (list != null && !list.isEmpty()) {
            int size = list.size();
            for (int i = 0; i < size; i++) {
                List<Object> objects = list.get(i);
                Object[] e = new Object[1];
                if (objects.get(2).equals("Y")) {
                    e[0] = objects.get(1);
                    result.add(e);
                }
            }
        }
        return result.iterator();
    }

    public static Iterator<Object[]> provideDefaultCategory() {
        List<Object[]> result = new ArrayList<>();
        List<List<Object>> list = ExcelUtil.getReader(path, 1).read(1);
        if (list != null && !list.isEmpty()) {
            int size = list.size();
            for (int i = 0; i < size; i++) {
                List<Object> rowList = list.get(i);
                if (rowList.get(2).equals("Y")) {
                    result.add(new Object[]{rowList.get(1)});
                }
            }
        }
        return result.iterator();
    }

    public static Iterator<Object[]> provideTheSpecialDay() {
        List<Object[]> result = new ArrayList<>();
        List<List<Object>> list = ExcelUtil.getReader(path, 2).read(1);
        if (list != null && !list.isEmpty()) {
            int size = list.size();
            for (int i = 0; i < size; i++) {
                List<Object> rowList = list.get(i);
                if (rowList.get(4).equals("Y")) {
                    result.add(new Object[]{rowList.get(1), rowList.get(2), rowList.get(3)});
                }
            }
        }
        return result.iterator();
    }
}


